package com.unionpay.upyzt.model;

import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.net.APIResource;
import com.unionpay.upyzt.resp.WithdrawableDepositResp;
import java.util.Map;
import lombok.experimental.Accessors;

/**
 * 可提现充值订单表
 */
@Accessors(chain = true)
public class WithdrawableDeposit extends APIResource {

    /**
     * 可提现充值
     *
     * @param params 参数
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static WithdrawableDepositResp create(Map<String, Object> params) throws UpyztException {
        return APIResource
            .request(RequestMethod.POST,
                classURL(WithdrawableDeposit.class), params,
                WithdrawableDepositResp.class, null);
    }

    /**
     * 可提现充值订单查询（系统订单号）
     *
     * @param withdrawableDepositId 提现充值id
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static WithdrawableDepositResp retrieveById(String withdrawableDepositId) throws UpyztException {
        return APIResource
            .request(RequestMethod.GET,
                instanceURL(WithdrawableDeposit.class, withdrawableDepositId), null,
                WithdrawableDepositResp.class, null);
    }

    /**
     * 可提现充值订单查询（平台订单号）
     *
     * @param outOrderNo 平台订单号
     * @return 返回结果
     * @throws UpyztException 异常
     */
    public static WithdrawableDepositResp retrieveByOutOrderNo(String outOrderNo) throws UpyztException {
        return APIResource
            .request(APIResource.RequestMethod.GET,
                instanceURL(WithdrawableDeposit.class, "_by_out_order_no", outOrderNo), null,
                WithdrawableDepositResp.class, null);
    }
}
